package com.compute.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author 李天航
 * 固定活动
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FixedEvent implements Serializable {
    private Integer eventId;
    private String eventName;
    private Long beginTime;
    private Long endTime;
    private Long weekNum;
    private String userAccount;
    private String eventType;
    private Integer finishTag=0;
    private Integer taskId=-1;
    private String from="固定活动";
    private String eventLocation;
    /**
     * 根据lesson和周数创建一个固定活动的对象
     * @param lesson 课程信息
     * @param weekNum 周数
     */
    public FixedEvent(Lesson lesson, Long weekNum)
    {
        this.eventName=lesson.getLessonName();
        this.beginTime=lesson.getBeginTime();
        this.endTime= lesson.getEndTime();
        this.weekNum=weekNum;
        this.userAccount=lesson.getUserAccount();
        this.eventType=lesson.getLessonType();
        this.finishTag =0;
        this.taskId=-1;
        this.from="每周活动";
        this.eventLocation=lesson.getLessonLocation();
    }

    /**
     * 使用每日活动一周中的第几天创建一个固定活动
     * @param dailyActivity 日常活动
     * @param weekNum 周数
     * @param day 第几天
     */
    public FixedEvent(DailyActivity dailyActivity, long weekNum, int day)
    {
        this.eventName=dailyActivity.getDailyName();
        this.userAccount= dailyActivity.getUserAccount();
        this.beginTime=dailyActivity.getBeginTime()+ (long) (day - 1) *24*60;
        this.endTime= dailyActivity.getEndTime() +(long) (day-1)*24*60;
        this.weekNum=weekNum;
        this.eventType=dailyActivity.getDailyType();
        this.finishTag =0;
        this.taskId=-1;
        this.from="每日活动";
        this.eventLocation=dailyActivity.getDailyLocation();
    }

    public FixedEvent(Task task,long beginTime)
    {
        this.eventName=task.getTaskName();
        this.beginTime=beginTime;
        this.endTime=beginTime+task.getTaskTime();
        this.weekNum=task.getWeekNum();
        this.userAccount= task.getUserAccount();
        this.eventType=task.getTaskType();
        this.finishTag =0;
        this.taskId=task.getTaskId();
        this.from="任务清单";
        this.eventLocation=task.getTaskLocation();
    }

    public FixedEvent(String userAccount, long weekNum) {
        this.userAccount=userAccount;
        this.weekNum=weekNum;
        this.taskId=-1;
        this.from="固定活动";
    }
}
